package com.ttg.web.controller.common;

import com.ttg.common.entities.BaseResult;
import com.ttg.common.utils.RequestParamsManager;
import com.ttg.model.dto.EditRulesStatusDto;
import com.ttg.model.dto.GetRulesListDto;
import com.ttg.web.service.RulesManagementService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/8/3 16:35
 */
@Api("规则管理（旧）")
@RestController
@RequestMapping("/rules")
public class RulesManagementController {

    @Autowired
    private RulesManagementService managementService;


    @PostMapping("/getRulesList")
    public BaseResult getRulesList(@RequestBody String data){
        GetRulesListDto dto = RequestParamsManager.transformRequestParam(data, GetRulesListDto.class);
        return BaseResult.success(managementService.getRulesList(dto));
    }

    @PostMapping("/editRulesStatus")
    public BaseResult editRulesStatus(@RequestBody String data){
        EditRulesStatusDto editRulesStatusDto = RequestParamsManager.transformRequestParam(data, EditRulesStatusDto.class);
        return BaseResult.success(managementService.editRulesStatus(editRulesStatusDto));
    }


}
